package ipdesk.model.report.excel;


import java.util.List;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.opensymphony.xwork2.Preparable;

public class ExcelDocumentAction extends ActionSupport implements Preparable, ModelDriven<DocumentBean>
{
	// 모델 드리븐에 사용되는 도메인 객체.
	private DocumentBean documentBean;
	
	// 엑셀 출력에 사용되는 도메인 객체
	private List<DocumentBean> documentBeanList;
	
	private String filename;
	
	private String templatePath;
	
	public String execute() throws Exception
	{
		
		// 해당 사용자의 해당 센터의 데이터를 가져온다.
		documentBeanList = ExcelDocumentDao.getInstance().getDataList(documentBean);
		
		return SUCCESS;
	}
	
	public void prepare() throws Exception
	{
		documentBean = new DocumentBean();
	}
	
	public DocumentBean getModel()
	{
		return documentBean;
	}

	public List<DocumentBean> getDocumentBeanList()
	{
		return documentBeanList;
	}

	public void setDocumentBeanList(List<DocumentBean> documentBeanList)
	{
		this.documentBeanList = documentBeanList;
	}
	
	public String getFilename()
	{
		filename = "";
		
		if(documentBean.getReportGubun().equals("consult"))
		{
			filename = "지재권상담일지";
		}
		else if(documentBean.getReportGubun().equals("brand"))
		{
			filename = "상표출원일지";
		}
		else if(documentBean.getReportGubun().equals("design"))
		{
			filename = "디자인출원일지";
		}
		else if(documentBean.getReportGubun().equals("invade"))
		{
			filename = "침해조사일지";
		}
		else if(documentBean.getReportGubun().equals("seminar"))
		{
			filename = "설명회_세미나실적";
		}
		else if(documentBean.getReportGubun().equals("channel"))
		{
			filename = "협력채널구축실적";
		}
		else if(documentBean.getReportGubun().equals("promote"))
		{
			filename = "홍보실적";
		}
		else if(documentBean.getReportGubun().equals("biz"))
		{
			filename = "기업정보";
		}
		else if(documentBean.getReportGubun().equals("consultAnalysis"))
		{
			filename = "침해대응_상세";
		}
		
		
		return filename;
	}

	public String getTemplatePath()
	{
		templatePath = "";
		
		if(documentBean.getReportGubun().equals("consult"))
		{
			templatePath = "/tpl/consult_tpl.xlsx";
		}
		else if(documentBean.getReportGubun().equals("brand"))
		{
			templatePath = "/tpl/brand_tpl.xlsx";
		}
		else if(documentBean.getReportGubun().equals("design"))
		{
			templatePath = "/tpl/design_tpl.xlsx";
		}
		else if(documentBean.getReportGubun().equals("invade"))
		{
			templatePath = "/tpl/invade_tpl.xlsx";
		}
		else if(documentBean.getReportGubun().equals("seminar"))
		{
			templatePath = "/tpl/seminar_tpl.xlsx";
		}
		else if(documentBean.getReportGubun().equals("channel"))
		{
			templatePath = "/tpl/channel_tpl.xlsx";
		}
		else if(documentBean.getReportGubun().equals("promote"))
		{
			templatePath = "/tpl/promote_tpl.xlsx";
		}
		else if(documentBean.getReportGubun().equals("biz"))
		{
			templatePath = "/tpl/biz_tpl.xlsx";
		}
		else if(documentBean.getReportGubun().equals("consultAnalysis"))
		{
			templatePath = "/tpl/consult_tpl_analysis.xlsx";
		}
		
		return templatePath;
	}
	
	
}
